package com.example.javabasic.sample.log;

import lombok.extern.slf4j.Slf4j;

/**
 * @author: cph
 * @date: 2021/10/13 10:23
 */
@Slf4j
public class PrintLogTest {

    // 等价于使用Lombok的@Slf4j
//    private static final Logger log = LoggerFactory.getLogger(PrintLogTest.class);

    public static void main(String[] args) {
        int param = 123;
        try {
            log.info("普通消息");
            // 带参数消息
            log.info("单个参数消息:[{}]", new Object());
            int i = 1 / 0;
        } catch (Exception e) {
//            log.info("异常消息", e);
//            log.error("异常消息", e);
//            log.error("异常消息"+param, e);
            // 可正常打印
//            log.error("异常消息:[{}]", param, e);
            // 错误示例
            log.error("异常消息:[{}], 异常消息:[{}]", param, e);
        }
    }
}
